package com.yx.crawler.runtime;

import java.util.List;
import com.yx.crawler.typedef.CrawlerListener;
import com.yx.crawler.typedef.CrawlerPage;
import com.yx.crawler.typedef.CrawlerUrl;
import com.yx.crawler.typedef.Policy;
import com.yx.frame.log.LogFactory;
import com.yx.frame.log.LogWriter;

public class CrawlerManager {	
	private CrawlerQueue crawlerQueue;
	private int concurrent = 1;

	public CrawlerManager(CrawlerQueue crawlerQueue) {
		this.crawlerQueue = crawlerQueue;
	}

	public CrawlerManager() {
		this.crawlerQueue = new BasicCrawlerQueue();
	}
	public void putCrawlerUrl(CrawlerUrl crawlerUrl)throws Exception{
		this.crawlerQueue.push(crawlerUrl);
	}
	public void start(int concurrent) {
		this.concurrent = concurrent > 0 ? concurrent : 1;
		for (int i = 0; i < this.concurrent; i++) {
			CrawlerProcessor crawlerProcessor = new CrawlerProcessor(crawlerQueue);
			crawlerProcessor.start();
		}
	}
}
